const FLOW_NODE_GROUP_MAP = [
	{"name":"简单分组","code":"simple","flows":["SimpleFlow"]}
];

const flowGroup = {
	"groupAll":function(flowNodes){
		let defaultFlowGroup = {
			"name":"默认分组",
			"code":"_default",
			"nodeList":[]
		};
		
		let groupMap = {};
		let groupList = [];
		for(let fgn of FLOW_NODE_GROUP_MAP){
			let tempFlowGroup = {
				"name":fgn.name,
				"code":fgn.code,
				"nodeList":[]
			};
			for(let ffs of fgn.flows){
				groupMap[ffs] = tempFlowGroup;
			}
			groupList.push(tempFlowGroup);
		}
		
		for(let fnode of flowNodes){
			if(groupMap[fnode.name]){
				groupMap[fnode.name].nodeList.push(fnode);
			}else{
				defaultFlowGroup.nodeList.push(fnode);
			}
		}
		
		return [defaultFlowGroup,...groupList.filter(function(gp){return gp.nodeList.length>0;})];
	}
	
	
};

export default flowGroup